/*
 * 易族智汇（北京）科技有限公司 版权所有。
 * 未经许可，您不得使用此文件。
 * 官方地址：www.javamall.com.cn
 */
package com.enation.app.javashop.core.client.feignimpl.trade;

import com.enation.app.javashop.client.trade.OrderOperateClient;
import com.enation.app.javashop.core.client.fallback.trade.OrderOperateClientFallbackFactory;
import com.enation.app.javashop.core.handler.FeignConfiguration;
import com.enation.app.javashop.model.trade.cart.dos.OrderPermission;
import com.enation.app.javashop.model.trade.order.dos.OrderDO;
import com.enation.app.javashop.model.trade.order.dos.OrderLogDO;
import com.enation.app.javashop.model.trade.order.dos.OrderOutStatus;
import com.enation.app.javashop.model.trade.order.dos.TransactionRecord;
import com.enation.app.javashop.model.trade.order.enums.OrderOutStatusEnum;
import com.enation.app.javashop.model.trade.order.enums.OrderOutTypeEnum;
import com.enation.app.javashop.model.trade.order.enums.OrderServiceStatusEnum;
import com.enation.app.javashop.model.trade.order.vo.CancelVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

/**
 * 订单操作SDK
 *
 * @author fk create in 2020/4/7
 * @version v2.0
 * @since v7.2.0
 */
@FeignClient(name = "trade-service", fallbackFactory = OrderOperateClientFallbackFactory.class,configuration = {FeignConfiguration.class})
public interface OrderOperateClientFeignImpl extends OrderOperateClient {


    /**
     * 更新订单项快照ID
     *
     * @param itemsJson
     * @param orderSn
     * @return
     */
    @Override
    @PutMapping("/client/orders/{order_sn}/item-json")
    void updateItemJson(@RequestParam("items_json") String itemsJson, @PathVariable("order_sn") String orderSn);

    /**
     * 添加交易快照
     * @param orderDO
     */
    @Override
    @PostMapping("/client/orders/goods-snapshot")
    void addGoodsSnapshot(@RequestBody OrderDO orderDO);

    /**
     * 更新订单的店铺名称
     * @param shopId
     * @param shopName
     */
    @Override
    @PutMapping("/client/orders/shop/{shop_id}/shop-name")
    void editOrderShopName(@PathVariable("shop_id") Long shopId,@RequestParam("shop_name") String shopName);

    /**
     * 订单取消
     *
     * @param cancelVO   取消vo
     * @param permission 需要检测的订单权限
     */
    @Override
    @PutMapping("/client/orders/cancel")
    void cancel(@RequestBody CancelVO cancelVO, @RequestParam("permission") OrderPermission permission);

    /**
     * 更新订单的售后状态
     *
     * @param orderSn
     * @param serviceStatus
     */
    @Override
    @PutMapping("/client/orders/{order_sn}/service/status")
    void updateServiceStatus(@PathVariable("order_sn") String orderSn, @RequestParam("service_status") OrderServiceStatusEnum serviceStatus);


    /**
     * 修改订单出库状态
     * @param orderSn 订单编号
     * @param typeEnum 出库类型
     * @param  statusEnum  出库状态
     * @return OrderOutStatus 订单出库状态
     */
    @Override
    @PutMapping("/client/orders/{order_sn}/out/status")
    void editOutStatus(@PathVariable("order_sn")String orderSn,@RequestParam("type_enum") OrderOutTypeEnum typeEnum,@RequestParam("status_enum") OrderOutStatusEnum statusEnum);

    /**
     * 添加交易记录表
     * @param transactionRecord 交易记录表
     * @return TransactionRecord 交易记录表
     */
    @Override
    @PostMapping("/client/orders/transaction-record")
    TransactionRecord addTransactionRecord(@RequestBody TransactionRecord transactionRecord);

    /**
     * 支付成功调用
     * @param tradeType
     * @param subSn 业务单号
     * @param returnTradeNo 第三方平台回传单号（第三方平台的支付单号）
     * @param payPrice 支付金额
     */
    @Override
    @PostMapping("/client/orders/pay-success")
    void paySuccess(@RequestParam("trade_type")String tradeType, @RequestParam("sub_sn")String subSn, @RequestParam("return_trade_no") String returnTradeNo,@RequestParam("pay_price") Double payPrice);


    /**
     * 添加订单出库状态
     * @param orderOutStatus 订单出库状态信息
     */
    @Override
    @PostMapping("/client/orders/order-out-status")
    void add(@RequestBody OrderOutStatus orderOutStatus);

    /**
     * 添加订单操作日志
     * @param logDO
     */
    @Override
    @PostMapping("/client/orders/order-log")
    void addOrderLog(@RequestBody OrderLogDO logDO);
}
